package org.ingeniart.siec.data;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Observes;
import javax.enterprise.event.Reception;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import org.ingeniart.siec.model.TipoDocumento;
import org.ingeniart.siec.service.TipoDocumentoRegistration;

@RequestScoped
public class TipoDocumentoListProducer{


	@Inject
	private TipoDocumentoRegistration tipoDocumentoRegistration;
	
	private List<TipoDocumento> list;
	
	
	public void onListChanged(@Observes(notifyObserver = Reception.IF_EXISTS) final TipoDocumento object)
	{
		System.out.println("Se ha activado esto");
		retrieveAllObjects();
	}

	@Produces
	@Named
	public List<TipoDocumento> getTipoDocumentos() {
		// TODO Auto-generated method stub
		return list;
	}
	
	@PostConstruct
	public void retrieveAllObjects() {
		list = tipoDocumentoRegistration.findAll();
	}

}
